let obj = {
    name: '康少',
    age: 18,
    like: {
        a: '唱',
        b: '跳',
        c: 'rap',
    },
    a: undefined,
    b: null,
    e: {}
}

function deepCopy(obj) {
    let newObj = {}
    for (let key in obj) {
        if (obj.hasOwnProperty(key)) {
            // 先判断 obj[key] 值的类型，如果是原始类型，直接赋值，如果是引用类型，xxxxx
            if (typeof obj[key] === 'object' && obj[key] !== null) {
                newObj[key] = deepCopy(obj[key])
            } else {
                newObj[key] = obj[key]
            }
        }
    }
    return newObj
}

let obj2 = deepCopy(obj)
obj.like.a = '篮球'

console.log(obj2);
